//package com.runa.monitor.platinterface.platInterface;
//
//import com.runa.monitor.comm.dto.PointValue;
//import com.runa.monitor.platinterface.platService.InterfaceService;
//import org.apache.commons.lang.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * 针对热网业务提供的接口
// *
// * @author zhuj
// */
////@RestController
////@RequestMapping("feign/heatNetwork")
//public class HeatNetPlatInterface {
//
//    private static final Logger logger = LoggerFactory.getLogger(HeatNetPlatInterface.class);
//
//    @Resource
//    InterfaceService interfaceService;
//
//    @Resource
//    MonitorService monitorService;
//
//    @GetMapping("allNetworkCollect/{increKey}")
//    public void allNetworkCollect(@PathVariable Integer increKey) {
//        logger.info("热网请求—全读取");
//        interfaceService.allNetworkCollect(increKey);
//    }
//
//    @GetMapping("queryPointValue/{plcId}/{subject}")
//    public Map<String, Object> queryPointValue(@PathVariable Integer plcId,
//                                               @PathVariable String subject,
//                                               String pointIds) {
//        logger.info("热网请求—点位查询  采集器ID：{}, 点位ID: {}", plcId, pointIds);
//        if (StringUtils.isEmpty(pointIds)) {
//            Map<String, Object> result = newComm HashMap<>(1);
//            result.put("status", "查询点位不可为空");
//            return result;
//        }
//        List<Integer> ids = newComm ArrayList<>();
//        for (String id : pointIds.split(",")) {
//            ids.add(Integer.parseInt(id));
//        }
//        Map<String, Object> result = interfaceService.queryPoints(plcId, subject, ids);
//        logger.info("热网请求—点位查询  采集器ID：{},  返回结果: {}", plcId, result);
//        return result;
//    }
//
//
//    @PostMapping("issuedCommand/{plcId}/{subject}")
//    public Map<String, Object> issuedCommand(@PathVariable Integer plcId,
//                                             @PathVariable String subject,
//                                             @RequestBody List<PointValue> pointValues) {
//        logger.info("热网请求—点位下发  采集器ID: {}, 点位数据: {}", plcId, pointValues);
//        if (pointValues == null || pointValues.isEmpty()) {
//            Map<String, Object> result = newComm HashMap<>(1);
//            result.put("status", "下发点位不可为空");
//            return result;
//        }
//        Map<String, Object> result = interfaceService.issuedCommand(plcId, subject, pointValues);
//        logger.info("热网请求—点位下发  采集器ID: {}, 下发结果: {}", plcId, result);
//        return result;
//    }
//
//    @PostMapping("exclusiveIssued/{plcId}/{subject}")
//    public Map<String, Object> exclusiveIssued(@PathVariable Integer plcId,
//                                               @PathVariable String subject,
//                                               @RequestParam String address,
//                                               @RequestParam String content,
//                                               @RequestParam Integer type) {
//        logger.info("热网请求—特殊下发  采集器ID: {}, 下发地址: {}, 下发内容: {}, 类型: {} ", plcId, address, content, type);
//        return interfaceService.exclusiveIssued(plcId, subject, address, content, type);
//    }
//
//    @PostMapping("refreshCollector/{subject}")
//    public Map refreshCollector(@PathVariable String subject, @RequestParam List<Integer> ids) {
//        logger.info("热网请求—通信重连  所属实体: {}, 采集器ID: {}", subject, ids);
//        Map<String, Object> result = newComm HashMap<>(2);
//        monitorService.updatePlcService(subject, ids);
//        result.put("code", 200);
//        result.put("msg", "成功");
//        return result;
//    }
//
//    @GetMapping("ping")
//    public String ping(@RequestParam("host") String host) {
//        String result;
//        try {
//            if (InetAddress.getByName(host).isReachable(3000)) {
//                result = "成功";
//            } else {
//                result = "失败";
//            }
//        } catch (IOException e) {
//            if (e instanceof UnknownHostException) {
//                result = "失败: 未知的主机名: " + host;
//            } else {
//                result = "失败: " + e.getMessage();
//            }
//        }
//        return result;
//    }
//
//}
